#ifndef __M_CTRL_PAD_H__
#define __M_CTRL_PAD_H__

#define ANALOG_CENTER 128
#define ANALOG_THRESHOLD 64
#define ANALOG_SENSITIVITY 16

enum CtrlPadKeys
{
    PAD_LEFT,
    PAD_UP,
    PAD_RIGHT,
    PAD_DOWN,
    PAD_CROSS,
    PAD_CIRCLE,
    PAD_SQUARE,
    PAD_TRIANGLE,
    PAD_L1,
    PAD_R1,
    PAD_L2,
    PAD_R2,
    PAD_L3,
    PAD_R3,
    PAD_SELECT,
    PAD_START,
    PAD_PSBUTTON,
    PAD_ENTER,
    PAD_CANCEL,
    PAD_LEFT_ANALOG_UP,
    PAD_LEFT_ANALOG_DOWN,
    PAD_LEFT_ANALOG_LEFT,
    PAD_LEFT_ANALOG_RIGHT,
    PAD_RIGHT_ANALOG_UP,
    PAD_RIGHT_ANALOG_DOWN,
    PAD_RIGHT_ANALOG_LEFT,
    PAD_RIGHT_ANALOG_RIGHT,
    PAD_N_BUTTONS
};
#define N_LOCAL_BUTTONS PAD_PSBUTTON

typedef uint8_t CtrlData[PAD_N_BUTTONS];
typedef uint32_t CtrlCount[PAD_N_BUTTONS];

typedef struct
{
    CtrlData old;
    CtrlData current;
    CtrlData pressed;
    CtrlData released;
    CtrlData hold;
    CtrlData hold2;
    CtrlData hold_count;
    CtrlData hold2_count;
    CtrlCount current_hold_count;
    CtrlCount old_hold_count;
} CtrlPad;

void resetPad(CtrlPad *pad);
void readPad(CtrlPad *pad);

#endif